package bforce;

import java.util.Date;
import java.util.List;

import common.CommonHelper;
import common.GeneticHelper;

import salb1.Salb1GeneticOperations;
import salb1.Salb1Genotype;
import salb1.TimeOfOperations;
import nsga.Individual;

public class BFRunner {

	public static void main(String argv[]) {
		System.out.println("Algorytm rozwiazujacy metoda pelnego przegladu");
		System.out.println("Czas startu "+(new Date()));

		TimeOfOperations top = null;
		
		if (argv.length != 3) {
		    System.out.println("Skladnia: program [plik_wejsciowy] [plik_wyjsciowy_wyniki] [plik_wyjsciowy_genotyp]");
		    System.exit(1);
		}
		try {
			top = new TimeOfOperations(argv[0]);
		}
		catch (Exception e) { e.printStackTrace(); }

		Salb1GeneticOperations go = new Salb1GeneticOperations(top);
		BFSolver<Salb1Genotype> bfs = new BFSolver<Salb1Genotype>(go);

		bfs.runExperiment();
		System.out.println("Eksperyment zakonczony");
		
		List<Individual<Salb1Genotype>> resultPopulation = bfs.getResult();
		String resultPopulationStr = GeneticHelper.populationValuesToString(resultPopulation);
		String resultGenotypePopulationStr = GeneticHelper.populationToString(resultPopulation);
		CommonHelper.printToFile(argv[1], resultPopulationStr);
		CommonHelper.printToFile(argv[2], resultGenotypePopulationStr);
		
		System.out.println("koniec nastapil o "+(new Date()));
	}

}
